function changeDirection(direction: "up" | "down" | "left" | "right") {
  switch (direction) {
    case "up":
      console.log("向上移动");
      break;
    case "down":
      console.log("向下移动");
      break;
    case "left":
      console.log("向左移动");
      break;
    case "right":
      console.log("向右移动");
      break;
    default:
      console.log("无效的方向");
  }
}
changeDirection("up");

enum Direction {
  Up,
  Down,
  Left,
  Right,
}
console.log(Direction.Down);

function getDirection(direction: Direction) {
  switch (direction) {
    case Direction.Up:
      console.log("向上移动");
      break;
    case Direction.Down:
      console.log("向下移动");
      break;
    case Direction.Left:
      console.log("向左移动");
      break;
    case Direction.Right:
      console.log("向右移动");
      break;
    default:
      console.log("无效的方向");
  }
}
getDirection(Direction.Down);
